/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       font.h
 * Author:     karooolek
 * Created on: 2009-03-24
 *
 **********************************************************************************************************************/

#ifndef FONT_H_
#define FONT_H_

#include "texturedmaterial.h"
#include "fontcharacter.h"
#include "../common.h"

namespace mGameEngine
{
namespace Graphics
{

/**
 * Font resource.
 * //TODO
 */
class Font
{
protected:
    /**
     * Font characters.
     */
    Map<uint16, FontCharacter> _chars;

    /**
     * Characters display lists.
     */
    Map<uint16, uint> _dls;

    /**
     * Font texture.
     */
    Texture *_texture;

public:
    /**
     * Create font.
     * Font has no default characters.
     */
    Font();

    /**
     * Destroy font.
     */
    virtual ~Font();

    /**
     * Get all font characters.
     * @return all font characters
     */
    const Map<uint16, FontCharacter> &getCharacters() const
    {
        return _chars;
    }

    /**
     * Get specified font character.
     * @param c character name
     * @return specified character
     */
    const FontCharacter &getCharacter(uint16 c) const;

    /**
     * Add character to font.
     * @param c character name
     * @param character character
     */
    void addCharacter(uint16 c, const FontCharacter &character);

    /**
     * Remove specified character from font.
     * @param c character name
     */
    void removeCharacter(uint16 c);

    /**
     * Get font texture.
     * @return font texture
     */
    const Texture *getTexture() const
    {
        return _texture;
    }

    /**
     * Set font texture.
     * @param texture font texture
     */
    void setTexture(Texture *texture)
    {
        _texture = texture;
    }

    /**
     * Calculate width of text drawn with this font.
     * @param text to calculate.
     */
    virtual float calcTextWidth(const String &text) const;

    /**
     * Draw text using this font.
     * @param text text to draw.
     */
    virtual void drawText(const String &text) const;
};

}
}

#endif // FONT_H_
